﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using VOL.Domain.IServices.WarehouseManagement;
using VOL.Entity.DomainModels;

namespace VOL.WebApi.Controllers.WarehouseManagement
{
    /// <summary>
    /// 产品入库控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class InboundProductsController : ControllerBase
    {
        private IInboundProductsService _inboundProductsService;

        public InboundProductsController(IInboundProductsService inboundProductsService)
        {
            _inboundProductsService = inboundProductsService;
        }

        /// <summary>
        /// 产品入库新增
        /// </summary>
        /// <param name="inboundProducts"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> AddInboundProducts([FromBody]InboundProducts inboundProducts)
        {
            return await _inboundProductsService.AddInboundProducts(inboundProducts);
        }
        /// <summary>
        /// 产品入库显示
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<InboundProducts>> GetAllInboundProducts(string? inboundCode, string? inboundName, string? workCode,int pageIndex = 1, int pageSize = 5)
        {
            return  await _inboundProductsService.GetAllInboundProducts(inboundCode, inboundName, workCode,pageIndex,pageSize);
        }
        /// <summary>
        /// 产品入库修改
        /// </summary>
        /// <param name="inboundProducts"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<int> UpdateInboundProducts([FromBody] InboundProducts inboundProducts)
        {
            return await _inboundProductsService.UpdateInboundProducts(inboundProducts);
        }
        /// <summary>
        /// 产品入库入库
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<int> DeleteInboundProducts(int id)
        {
            return await _inboundProductsService.DeleteInboundProducts(id);
        }
    }
}
